#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Creative Exercises 1.2.24 - Loan payments
http://introcs.cs.princeton.edu/java/12types/index.php#exercises

Syntax:
python loan_payments.py 3 2340 3.1


Notes:
math is a required import here for the expml() function for variable epsilon.
https://docs.python.org/2/library/math.html

round will round to ndigits after the decimal point.
https://docs.python.org/2/library/functions.html#round

'''

import sys
import math


def main():
    ''' Calculate payments w/continuously compounded interest '''

    years = int(sys.argv[1])
    principal = int(sys.argv[2])
    interest_rate = float(sys.argv[3]) / 100
    months = 12 * years

    print 'Calculating monthly payments using:'
    summary = 'Years: {}\nPrincipal: {}\nInterest Rate: {}'
    print summary.format(years, principal, interest_rate)

    total = round((principal * math.exp(interest_rate * years)), 2)
    print "Total Owed: ", total

    m_payment = round((principal * math.exp(interest_rate * years))/months, 2)
    print "Monthly Payment: ", m_payment


if __name__ == '__main__':
    main()
